package com.yunyan.resp;

import lombok.Data;

@Data
public class JsonResp {

    private int code;

    private String msg;

    private Object data;

    public static JsonResp error(){
        JsonResp resp = new JsonResp();
        resp.setCode(500);
        return resp;
    }

    public static JsonResp error(int code ,String msg) {
        JsonResp resp = new JsonResp();
        resp.setCode(code);
        resp.msg = msg;
        return resp;
    }

    public static JsonResp error(String msg) {
        JsonResp resp = new JsonResp();
        resp.setCode(500);
        resp.msg = msg;
        return resp;
    }

    public static JsonResp ok(){
        JsonResp resp = new JsonResp();
        resp.setCode(200);
        return resp;
    }

    public static JsonResp ok(Object data){
        JsonResp resp = new JsonResp();
        resp.setCode(200);
        resp.setData(data);
        return resp;
    }
}
